package com.hcy.customer.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.hcy.common.CommonInfoBz;
import com.hcy.customer.CarLevelInfoRequest;
import com.hcy.customer.CarLevelInfoResponse;
import com.hcy.customer.CustomerRuntimeBz;
import com.hcy.driver.entity.CarLevel;
import com.hcy.driver.service.impl.CarLevelServiceImpl;
import com.hcy.rabbitbasicutils.utils.GaoDeUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author huchenying
 * @Description
 * @Date 2022/3/11 19:35
 */
@Service
public class CustomerRuntimeBzImpl<A> implements CustomerRuntimeBz {

    @Autowired
    private CarLevelServiceImpl carLevelService;

    @Autowired
    private GaoDeUtils gaoDeUtils;

    @Autowired
    private CommonInfoBz commonInfoBz;

    @Override
    public List<CarLevelInfoResponse> getCarLevelInfo(CarLevelInfoRequest request) {
        LambdaQueryWrapper<CarLevel> wrapper = new LambdaQueryWrapper<>();
        wrapper.ne(CarLevel::getEnable,0);
        List<CarLevel> list = carLevelService.list(wrapper);
        // 计算距离，根据车辆等级获取价格信息返回
        Integer distance = gaoDeUtils.getDistance(request.getStartLatitude(), request.getStartLongitude(), request.getEndLatitude(), request.getEndLongitude());
        //获取价格列表
        return commonInfoBz.getLevelPriceList(distance, list);
    }
}
